#include "sys.h"
static bit flag = 1;
unsigned char code smg[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff,0xbf,0xc6};
u8 NixieBuff[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
u8 smg1,smg2,smg3,smg4,smg5,smg6,smg7,smg8;

void nixie_scan()
{
	static u8 index;
	P0 = 0xff;
	hc138(7);
	hc138(0);
	
	P0 = 0x01<<index;
	hc138(6);
	hc138(0);
	
	P0 = NixieBuff[index];
	hc138(7);
	hc138(0);
	index++;
	index &= 0x07;
	P0 = 0xff;
}

void nixie_show()
{
	NixieBuff[0] = smg[smg1];
	NixieBuff[1] = smg[smg2];
	NixieBuff[2] = smg[smg3];
	NixieBuff[3] = smg[smg4];
	NixieBuff[4] = smg[smg5];
	NixieBuff[5] = smg[smg6];
	NixieBuff[6] = smg[smg7];
	NixieBuff[7] = smg[smg8];
	
}


void showMode1()
{
	smg1 = 11;
	smg2 = showMode;
	smg3 = 11;
	smg4 = 10;
	smg5 = 0;
	smg6 = WorkTime/100;
	smg7 = WorkTime%100/10;
	smg8 = WorkTime%10;
}

void showMode2()
{
		smg1 = 11;
		smg2 = 4;
		smg3 = 11;
		smg4 = 10;
		smg5 = 10;
		smg6 = Temp/10;
		smg7 = Temp%10;
		smg8 = 12;
}

void show()
{
	
	if(S7 == 0)
	{
		delay1ms(5);
		while(!S7);
		flag = ~flag;
	}
	if(flag)
	{
		showMode1();
	}else{
		showMode2();
	}
}